package com.heima.media.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * 异步有返回值的调用
 */
@Component
public class A {

    @Autowired
    private B b;

    @Autowired
    private C c;

    @Autowired
    private D d;

    public void a() throws ExecutionException, InterruptedException {
        long time1 = System.currentTimeMillis();
        Future<Long> b = this.b.b(); //有返回值的异步调用（同审核那块的异步）方法调用者
        Future<Long> c = this.c.c();//有返回值的异步调用（同审核那块的异步） 方法调用者
        Future<Long> d = this.d.d();//有返回值的异步调用（同审核那块的异步）方法调用者
        System.out.println("b:"+b.get()+",c:"+c.get()+",d:"+d.get());//有返回值的异步调用（同审核那块的异步）
        long time2 = System.currentTimeMillis();
        System.out.println(time2-time1);
    }

}
